package com.tvunetworks.device.extra.common.feign;

import com.github.pagehelper.PageInfo;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.gs.model.Device;
import com.tvunetworks.device.extra.common.model.*;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Set;


/**
 * @author Etan Yang
 * @create: 2021/12/3 17:08
 */

@RequestMapping({"/feign"})
public interface DeviceExtraInterface {
    /**
     * 分页查询所有的source
     *
     * @param param PageDeviceParam
     * @return 分页结果
     */
    @PostMapping("/pageAllSource")
    Result pageAllSource(@RequestBody PageDeviceParam param);

    /**
     * 移除指定receiver下所有的token配对
     *
     * @param receiverId receiver的peerId
     * @param userId     用户的Id
     * @param origin     origin
     * @return 返回结果
     */
    @PostMapping("/removeAllTokenPair")
    Result removeTokenPair(@RequestParam("receiverId") String receiverId, @RequestParam("userId") String userId, @RequestParam("origin") int origin);

    /**
     * 分页查询用户下指定设备
     * @param param 参数
     * @return 返回各种类型设备的分页结果
     */
    @PostMapping("/pageDeviceOfUser")
    Result<PageInfo<Device>> pageDeviceOfUser(@RequestBody PageDeviceOfUserParam param);

    /**
     * 当设备状态发生变化时,发送至mq   offline-->online
     * @param message 消息体
     */
    @PostMapping("toRabbitMQByDeviceOnline")
    void toRabbitMQByDeviceOnline(String message);
    /**
     * 当设备状态发生变化时,发送至mq  online-->live
     * @param message 消息体
     */
    @PostMapping("toRabbitMQByDeviceLive")
    void toRabbitMQByDeviceLive(String message);

    /**
     * 给T和R进行配对并且live
     * @param param param
     * @return 是否成功
     * @throws Exception 编译异常
     */
    @PostMapping("devicePairAndStartLive")
    Result<String> devicePairAndStartLive(PariOrRemoveAndStartOrStopLiveParam param) throws Exception;

    /**
     * 给T和R取消配对并且stoplive
     * @param param param
     * @return 是否成功
     * @throws Exception 编译异常
     */
    @PostMapping("deviceRemovePairAndStopLive")
    Result<String> deviceRemovePairAndStopLive(PariOrRemoveAndStartOrStopLiveParam param) throws Exception;

    /**
     * 根据用户Id,获取PP,Channel,CC中的Rid
     * @param userId 用户id
     * @return rid集合
     */
    @GetMapping("getUserReceiver")
    Result<Set<String>> getUserReceiver(@RequestParam("userId") String userId) ;

    /**
     * 根据用户id,获取用户下全部的R的信息
     * @param userId 用户id
     * @return R的device对象信息
     */
    @GetMapping("getDeviceByUserId")
    Result<List<Device>> getDeviceByUserId(@RequestParam("userId") String userId) ;

    /**
     * 根据rid移除grid
     * @param rid rid
     * @return r
     */
    @GetMapping("delete/grid")
    Result deleteGird(@RequestParam (value = "rid",required = false) String rid,
                      @RequestParam(value = "targetId",required = false) String programId,
                      @RequestParam(value = "pairId", required = false)String pairId);

    /**
     * 根据ObjectId,解析出sourceId,并配对,开启live
     * @param param param
     * @return success
     */
    @PostMapping("startLiveByObjectId")
    Result<String> startLiveByObjectId(@RequestBody ObjectIdStartLiveParam param) throws Exception;

    /**
     * 根据ObjectId,解析出sourceId,并停止lvie,和取消配对
     * @param param param
     * @return success
     */
    @PostMapping("stopLiveByObjectId")
    Result<String> stopLiveByObjectId(@RequestBody ObjectIdStopLiveParam param) throws Exception;

}
